use cortex_m::{asm::bootload, interrupt::free};


pub unsafe fn boot2(vtor_addr: u32) {
    free(|_| {
        let nvic: stm32f1::stm32f103::NVIC = unsafe {
            ::core::mem::transmute(())
        };
        for reg in nvic.icer.iter() {
            reg.write(0xFFFFFFFF);
        }
        for reg in nvic.icpr.iter() {
            reg.write(0xFFFFFFFF);
        }
        let sys: stm32f1::stm32f103::SYST = ::core::mem::transmute(());
        sys.csr.write(0);
        sys.rvr.write(0);
        sys.cvr.write(0);

        let rcc: stm32f1::stm32f103::RCC = ::core::mem::transmute(());
        rcc.ahbenr.reset();
        rcc.apb1enr.reset();
        rcc.apb2enr.reset();
    });
    bootload(vtor_addr as *const u32);
}










